<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer">
  <header class="mdl-layout__header">
    <div class="mdl-layout__header-row">
      <span class="mdl-layout__title"><%= title %></span>
    </div>
  </header>

  <%= erb :"../../global/navigation" %>

  <main class="mdl-layout__content" style="padding: 40px">
    <h3>Your projects</h3>
    <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
      <thead>
        <tr>
          <th>Status</th>
          <th style="width: 300px; text-align: center">Project Name</th>
          <th>Enabled</th>
        </tr>
      </thead>
      <tbody>
        <% projects_with_access.each do |project| %>
          <tr style="cursor: pointer;" onclick="location.href='/projects_erb/<%= project.id %>'">
            <td>
              <%= erb(:"../../build/views/build_status", locals: { status: project.builds.first&.status }) %>
            </td>
            <td style="text-align: center;"><%= project.project_name %></td>
            <td><%= project.enabled ? "✅" : "🚫" %></td>
          </tr>
        <% end %>
      </tbody>
    </table>

    <br />

    <% if projects_without_access.count > 0 %>
      <h3>There are some projects you don't have access to</h3>
      <p>to gain access to any repos you are missing from your organization, reach out to your GitHub org admin. They'll have to give you write access to the repo</p>
      <br />
    <% end %>

    <a href="/projects_erb/add" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">
      Add new Project
    </a>

  </main>
  <p type="text" 
     class="mdl-layout__content"
     readonly="true"
     style="font-size: .73em; font-weight: bold; padding: 40px">
    <% if defined?(server_version) && server_version %>
      server-version: 
      <a href="https://github.com/fastlane/ci/commit/<%= server_version %>" 
         target="_blank">
        <%= server_version %>
      </a>
    <% end %>
  </p>
</div>
